package com.gong.springmvc;


import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/res")

//想返回视图，就使用controller
//@RestController
@Controller
public class ResponseController {
    @RequestMapping("/index")
    public String index(){
        return "index.html";
    }

    @ResponseBody
    @RequestMapping("/indexData")
    public String indexData(){
        return "返回数据";
    }

    @ResponseBody
    @RequestMapping("/indexData2")
    public String indexData2(){
        return "<h1>我是中国人<h1>";
    }

    @ResponseBody
    @RequestMapping("/getStatus")
    public String getMap(HttpServletResponse response){
        response.setStatus(401);
        return "设置状态码";
    }


}
